#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: crud.py
# @time: 2021/4/29 10:58
# @desc:
from datetime import datetime
from typing import Optional, Dict

from views.configs import CATPART_OSS_ADDRESS
from views.tag import parameterTagInit


def generate_parameter_model_data(
        number: str,
        file_path: str,
        desc: str = "",
        version: str = "1.0",
        isFeature: bool = False,
        isFlag: bool = False,
) -> Dict:
    """

    Args:
        number:
        file_path:
        desc:
        version:
        isFeature:
        isFlag:

    Returns:

    """
    model = {
        "number": number,
        "time": datetime.now().strftime("%Y-%m-%d %H:%M"),
        # 存到数据库的name字段只应当包含最后一层的名字
        "name": file_path.split("/")[-1],
        "desc": desc,
        "type": "5",
        "version": version,
        "isFeature": isFeature,
        "isFlag": isFlag,
        "tag": parameterTagInit(),
        "file": {
            CATPART_OSS_ADDRESS: file_path,
            "transferFormatMessage": "not transfered yet",
        },
    }

    return model
